home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
4_0
/
LISTMANA
/
__TESTER
/
TEXTEDIT.C
< prev
next >
Wrap
Text File
|
1989-06-25
|
6KB
|
254 lines
/**** */
/**** List Testing Code version 1.0 (beta) */
/**** */
/**** All portions of this source code are the property of Jack */
/**** Herrington. I, Jack Herrington, give you permission to use */
/**** use or alter the code in any way that pleases you. You must */
/**** however return by whatever means avaliable any improvements */
/**** you believe significant to Jack Herrington, accepting that */
/**** these improvements might be contained in later releases of */
/**** the code. I also grant you permission to remove this header */
/**** from any file you are WORKING on, as long as you put it back */
/**** when you're stopped WORKING on it. */
/**** */
/**** Jack Herrington: University Of Miami, Biomedical Computing */
/**** 1600 N.W. 10th Ave. (R-53) */
/**** (305) 547-6538 */
/**** */
/****/
/**** TextEdit List Handler */
/****/
#include "ListManager.h"
#include "Tester.h"
#include "TextEditList.h"
/****/
/**** TextEdit List main dispersion routine */
/****/
void TextEditListHandler(mess,data)
int mess;
unsigned char *data;
{
switch(mess)
{
case MESS_NEW: TextEditListHandlerNew(); break;
case MESS_HIT: TextEditListHandlerHit((int *)data); break;
case MESS_CLOSE: TextEditListHandlerClose(); break;
case MESS_ACTIVATE: TextEditListHandlerActivate(1); break;
case MESS_DEACTIVATE: TextEditListHandlerActivate(0); break;
}
}
/****/
/**** Respond to a new message */
/****/
void TextEditListHandlerNew()
{
TextEditWindowInfo *tewi;
/**** Create the dialog */
if ( TesterDialogNew(1002,CurHandler) == (-1) ) return;
SetPort(Windows[CurWindow].window);
/**** Allocate the window record */
TesterAllocateWindowData((long)sizeof(TextEditWindowInfo));
TesterLockWindowInfo();
tewi = (TextEditWindowInfo *)TesterGetWindowInfo();
/**** Setup the window */
TextEditListHandlerSetupList(tewi);
/**** Unlock the window information and leave */
TesterUnLockWindowInfo();
}
/****/
/**** Setup the list */
/****/
void TextEditListHandlerSetupList(tewi)
TextEditWindowInfo *tewi;
{
TextStyle style;
Handle item;
Point cellSize,cell;
Rect box,dBox;
char charTmp[255];
int type,y,width;
/**** Get the box for the list */
GetDItem(Windows[CurWindow].window,ListBox,&type,&item,&box);
SetDItem(Windows[CurWindow].window,ListBox,type,TextEditListHandlerUpdate,&box);
/**** Create the data bounds */
dBox.left = 0; dBox.right = MAX_X;
dBox.top = 0; dBox.bottom = MAX_Y;
cellSize.h = 80; cellSize.v = 15;
/**** Create the list */
tewi->nlh = ListNew(&box,&dBox,cellSize,0,
Windows[CurWindow].window,0,0,0,1);
/**** Setup global cell definitions */
ListSetFrameWidth(1,15,tewi->nlh);
ListSetFrameDrawer(TextEditListHandlerDrawFrame,tewi->nlh);
ListSetGlobalBox(ListBottom,tewi->nlh);
ListSetGlobalFont(times,12,0,tewi->nlh);
ListSetScrollMethod(incMethod,tewi->nlh);
ListSetColumnWidth(0,(box.right-box.left)-17,tewi->nlh);
ListSetAddative(-1,-1,tewi->nlh);
/**** Set the cells */
style.tsFont = times;
style.tsSize = 12;
style.tsFace = 0;
cell.h = 0;
for(y=0;y<MAX_Y;y++)
{
(void)sprintf(charTmp,BigString[y]);
tewi->text[y] = TEStylNew(&box,&box);
TESetText(charTmp,(long)strlen(charTmp),tewi->text[y]);
TESetSelect(0L,6000L,tewi->text[y]);
TESetStyle((doFont|doFace|doSize),&style,FALSE,tewi->text[y]);
cell.v = y;
cell.h = 0;
ListSetHandler(TEUpdateHandler,cell,tewi->nlh);
ListSetData((Handle)tewi->text[y],cell,tewi->nlh);
width = ListCalTextWidth(cell,tewi->nlh) + 5;
ListSetRowWidth(cell.v,width,tewi->nlh);
}
/**** Setup the flags */
ListSetEhancedFlags((NoTrackOutside),tewi->nlh);
ListDoDraw(TRUE,tewi->nlh);
}
/****/
/**** Draw the list */
/****/
pascal void TextEditListHandlerUpdate(Window,ItemNumber)
WindowPtr Window;
int ItemNumber;
{
TextEditWindowInfo *tewi;
/**** Lock the window information and update */
SetPort(Window);
TesterLockWindowInfoWindow(Window);
tewi = (TextEditWindowInfo *)TesterGetWindowInfoIndirect(Window);
ListUpdateWhole(tewi->nlh);
TesterUnLockWindowInfoWindow(Window);
}
/****/
/**** Hit in the window */
/****/
void TextEditListHandlerHit(hit)
int *hit;
{
TextEditWindowInfo *tewi;
Point cell,lpt;
Rect sizeArea;
int part;
/**** Lock the window information */
TesterLockWindowInfo();
tewi = (TextEditWindowInfo *)TesterGetWindowInfo();
SetPort(Windows[CurWindow].window);
/**** Disperse according to dialog hit */
if ( *hit == ListBox )
{
GetMouse(&lpt);
part = ListPart(lpt,&cell,tewi->nlh);
switch(part)
{
case inHorizScroll:
case inVertScroll:
case inCell:
ListCickEnhanced(lpt,0,tewi->nlh,ListSingleDrag);
break;
}
}
/**** Unlock the window information */
TesterUnLockWindowInfo();
}
/****/
/**** Activate or DeActivate the list */
/****/
void TextEditListHandlerActivate(act)
int act;
{
TextEditWindowInfo *tewi;
TesterLockWindowInfo();
tewi = (TextEditWindowInfo *)TesterGetWindowInfo();
ListActivate(act,tewi->nlh);
TesterUnLockWindowInfo();
}
/****/
/**** Draw the frame title */
/****/
void TextEditListHandlerDrawFrame(message,visBox,cell)
int message;
Rect *visBox;
int cell;
{
char charTmp[255];
int width;
/**** Draw the message into the frame */
if ( message == HorizCell )
{
width = StringWidth(ColumnTitle) + 5;
MoveTo(visBox->right-width,visBox->bottom-2);
DrawString(ColumnTitle);
}
}
/****/
/**** Close up the window */
/****/
void TextEditListHandlerClose()
{
TextEditWindowInfo *tewi;
TesterLockWindowInfo();
tewi = (TextEditWindowInfo *)TesterGetWindowInfo();
ListDispose(tewi->nlh);
TesterUnLockWindowInfo();
TesterKillWindow(CurWindow);
}